<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('resource'); ?>
	<script type="text/javascript" src="<?php echo JS_DIR; ?>imgpreview.full.0.22.jquery.js"></script>
<?php $this->_endblock(); ?>
<?php $this->_block('title'); ?>
	Setup Creatives
<?php $this->_endblock(); ?>


<?php $this->_block('contents'); ?>
<div id="content" class="box">
	<h1>Setup Creatives</h1>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
		<fieldset>
			<legend>Setup Creatives</legend>
		<?php 
				if (isset($errors)) 
				{
					foreach ($errors as $error)
					{
		?>
				<p class="msg error"><?php echo $error;?></p>
		<?php		}
				}
		?>
	<form method="post" action="<?php echo url('offer/creatives'); ?>">
		<input type="hidden" name="offer_id" value="<?php echo $offer_id; ?>" />
		<?php 
			if(null != $creatives){
		?>
		<table>
			<tr>
				<th>Creative Name</th>
				<th>Url / Html</th>
				<th></th>
			</tr>
		<?php 
				foreach ($creatives as $creative):
		?>
			<tr>
				
				<td><label><?php echo $creative['name']; ?></label></td>
				<td>
					<?php 
						if(!empty($creative['url'])){
							echo '<a href="' .  $creative['url'] .'">' . $creative['url'] .'</a><br/>';
						}elseif(!empty($creative['html'])){
							echo '<a href="' .  $creative['html'] .'" target="_blank">' . $creative['html'] .'</a><br/>';
						}
					?>
				</td>
				<td><input type="checkbox" name="creatives[]" value="<?php echo $creative['id']; ?>" 
				<?php echo (!empty($creative_ids) && in_array($creative['id'], $creative_ids)) ? 'checked="checked"' : '' ; ?>/></td>					
		<?php 			
				endforeach;
			}else{
				echo '<a href="' . url('creative/add') . '">Add new Creatives</a><br/>';
			}
		?>	</tr>
		</table>
		<input type="submit" value="Setup"/>
	</form>
	</fieldset>
</div>
<script type="text/javascript">
	$(function(){
		$('table a').imgPreview();
	});
</script>
<?php $this->_endblock(); ?>